<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title></title>
    <script src="${pageContext.request.contextPath}/js/jquery-3.3.1.min.js"></script>
</head>
<body>
    <h3>隐式对象</h3>
    参数，用户名：${param.username} <br>
    参数，爱好：${paramValues.hobbies[0]} <br>
    会话id：${pageContext.session.id} <br>
    Web应用的路径：${pageContext.request.contextPath} <br>

    验证码：<img src="${pageContext.request.contextPath}/code" alt="">

    <h3>EL运算</h3>
    ${age+2} <br>
    ${age>30} <br>
    ${age>=18 ? '成年' : '未成年'} <br>
    ${not empty address}

    <h2>在JS中使用EL</h2>
    <script>
        var age = ${age}
        console.log(age)

        var address = '${address}'
        console.log(address)
    </script>

    <h2>JSTL的使用</h2>
    <c:if test="${age>=18}">
        <p>你已成年</p>
        <a href="">百度</a>
    </c:if>
    <c:if test="${age<18}">
        <p>您尚未成功</p>
        <a href="">新浪</a>
    </c:if>
    <br>

    <c:choose>
        <c:when test="${age>=60}">老年</c:when>
        <c:when test="${age>=40}">中年</c:when>
        <c:when test="${age>=18}">少年</c:when>
        <c:otherwise>童年</c:otherwise>
    </c:choose>
    <br>

    <table>
        <tr>
            <th>序号</th>
            <th>姓名</th>
            <th>年龄</th>
            <th>性别</th>
            <th>爱好</th>
        </tr>
        <c:forEach items="${users}" var="u" varStatus="status" begin="1" end="2">
            <tr>
                <td>${status.index},${status.count},${status.first},${status.last}</td>
                <td>${u.name}</td>
                <td>${u.age}</td>
                <td>${u.sex}</td>
                <td>${u.hobby}</td>
            </tr>
        </c:forEach>
    </table>
    <br>

    <c:forEach begin="1" end="${age}" var="num">
        <p>${num}</p>
    </c:forEach>
    <hr>

    出生日期：<fmt:formatDate value="${birthday}" pattern="yyyy年MM月dd日 HH:mm:ss" />

</body>
</html>
